/**
 * 
 */
package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import view.View;

/**
 * @author ezuera
 *
 */
public class NewArbeitspaketWindowListener implements ActionListener {

	/** Referenz auf das Controllerobjekt */
	private Controller controller;
	
	public NewArbeitspaketWindowListener(Controller controller) {
		this.controller = controller;
	}
	/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		switch(e.getActionCommand()) {
		case View.NEWAP:
			try {
				this.controller.saveNew(View.NEWAP);
				this.controller.closeNewProject();
			} catch (NoSuchFieldException er) {
				this.controller.showFehler(er.getMessage());
			}
			break;
		case View.CLOSECHOOSER:
			this.controller.closeNewProject();
		case View.PROJECTWAHL:
			this.controller.changeAPOption();
			break;
		case View.APUPDATEN:
			try {
				this.controller.saveNew(View.APUPDATEN);
				this.controller.getView().getNewArbeitspaket().dispose();
				this.controller.getView().getProjectWindow().dispose();
				this.controller.openProject();
			} catch (NoSuchFieldException er) {
				this.controller.showApFehler(er.getMessage());
			}
		}
	}

}
